<template>
	<div>
		<van-nav-bar title="我的" />
		<div style="display: flex;padding:5px;">
			<img src="../../../assets/amin_image.jpg" style="width: 64px;height: 64px;" />
			<div style="margin-left: 10px;">
				<div>{{userObj.name}}</div>
				<div style="margin-top: 6px;">{{userObj.email}}</div>
			</div>
		</div>
		<van-cell title="用户名" :value="userObj.username" />
		<van-cell title="电话" :value="userObj.phone" />
		<van-cell title="电话2" :value="userObj.phone2" />
		<van-cell title="传真" :value="userObj.fax" />
		<van-cell title="出生日期" :value="userObj.birthday" />
		<van-cell title="销售代表" :value="userObj.sales_rep" />
		<van-cell title="开发人员" :value="userObj.developer" />
		<van-cell title="描述" :value="userObj.description" />
		<van-button size="small" @click="onExitClickHandler" :block="true" type="primary">退出</van-button>
	</div>
</template>

<script>
	import {
		Dialog
	} from 'vant';
	import restUtil from '@/utils/restUtil.js';
	export default {
		name: "MMy",
		data() {
			return {
				userObj: {}
			}
		},
		mounted() {
			this.init();
		},
		methods: {
			init() {
				var that = this;
				restUtil.getAction(this,"mmy/init").then(
					function(response) {
						if (response.data.code == 1) {
							that.userObj = response.data.userObj;
						} else {
							Dialog.alert({
								title: '提示',
								message: response.data.message,
							}).then(() => {
								// on close
							});
						}
					});
			},onExitClickHandler(){
				var that=this;
				restUtil.postAction(this,"mmy/logout").then(
					function(response) {
						if (response.data.code == 1) {
							window.localStorage.setItem("token","");
							that.$router.push("/mlogin");
						} else {
							Dialog.alert({
								title: '提示',
								message: response.data.message,
							}).then(() => {
								// on close
							});
						}
					});
				
			}
		},
	}
</script>

<style>
</style>
